package com.hqyj.bigdata.hiveproject.controller;

import com.hqyj.bigdata.hiveproject.entity.TopTenCatalogInfo;
import com.hqyj.bigdata.hiveproject.json.R;
import com.hqyj.bigdata.hiveproject.service.TopTenCatalogInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

@RequestMapping("catalog")
@RestController //表示所有接口返回的都是json数据

public class TopTenCatalogInfoController {


    @Resource
    private TopTenCatalogInfoService topTenCatalogInfoService;


    @GetMapping("topTen")
    public R queryTopTenCatalogInfoList(){
        try{
            List<TopTenCatalogInfo> topTenCatalogInfoList = topTenCatalogInfoService.queryTopTenCatalogInfoList();

            return R.success("查询播放量前十名的板块信息列表成功！",topTenCatalogInfoList);
        }catch (Exception ex){
            ex.printStackTrace();
            return R.error("程序出现异常！");
        }
    }


    @GetMapping("topTwenty")
    public R queryTopTwentyCatalogInfoList(){
        try{
            List<TopTenCatalogInfo> topTenCatalogInfoList = topTenCatalogInfoService.queryTopTwentyCatalogInfoList();

            return R.success("查询播放量前二十名的板块信息列表成功！",topTenCatalogInfoList);
        }catch (Exception ex){
            ex.printStackTrace();
            return R.error("程序出现异常！");
        }
    }
}
